<style scoped>
  .case_detail_box * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-size: 0;
    cursor: default;
  }

  .case_detail_box {
    overflow: auto;
    height: 100%;
  }

  .case_detail_box .case_detail_title {
    font-size: 26px;
    color: #2877be;
    /*padding-left: 20px;*/
    text-align: center;
  }

  .item, .label, .value {
    display: inline-block;
  }

  .label, .value {
    font-size: 14px;
  }

  .item {
    width: 50%;
    padding-left: 20px;
    min-height: 30px;
    line-height: 30px;
    border-top: 1px #d1d9dd solid;
    overflow: hidden;
    vertical-align: top;
  }

  .label {
    width: 140px;
    cursor: auto !important;
    vertical-align: top;
    user-select: text !important;
  }

  .value {
    width: calc(100% - 140px);
    cursor: text !important;
    user-select: text !important;
  }

  .row {
    width: 100% !important;
    border-bottom: 1px #d1d9dd solid;
  }

  .control_bar {
    /*border-bottom: 1px solid #d1d9dd;*/
    padding-bottom: 10px;
    padding-left: 20px;
    text-align: center;
  }

  .control_bar .first,
  .control_bar .prev,
  .control_bar .next,
  .control_bar .last {
    display: inline-block;
    width: 20px;
    height: 20px;
    margin-top: 1px;
  }

  .control_bar .first {
    background: url("~@/assets/img/ajdj/arrow-l-.png") no-repeat;
    margin-right: 10px;
  }

  .control_bar .first:hover {
    background: url("~@/assets/img/ajdj/arrow-l--.png") no-repeat;
  }

  .control_bar .prev {
    background: url("~@/assets/img/ajdj/arrow-l1.png") no-repeat;
    margin-right: 20px;
  }

  .control_bar .prev:hover {
    background: url("~@/assets/img/ajdj/arrow-l.png") no-repeat;
  }

  .control_bar .next {
    background: url("~@/assets/img/ajdj/arrow-r.png") no-repeat;
    margin-left: 20px;
    margin-right: 10px;
  }

  .control_bar .next:hover {
    background: url("~@/assets/img/ajdj/arrow-r1.png") no-repeat;
  }

  .control_bar .last {
    background: url("~@/assets/img/ajdj/arrow-r-.png") no-repeat;
  }

  .control_bar .last:hover {
    background: url("~@/assets/img/ajdj/arrow-r--.png") no-repeat;
  }

</style>

<template>
  <div class="case_detail_box">
    <div class="case_detail_title">案件基本信息</div>
    <div class="item" :class="key==='AQZY'?'row':''" v-for="(value,key) in ajjbxxData_ZH">
      <div class="label break">{{value}}:</div>
      <div class="value break" :title="ajjbxx[key]">{{ajjbxx[key]}}</div>
    </div>

    <div class="case_detail_title" style="margin-top: 10px;">嫌疑人基本信息</div>
    <div class="control_bar">
      <div title="第一页" class="first" @click="xyrjbxxIndex=0"></div>
      <div title="上一页" class="prev" @click="xyrjbxxIndex>0?xyrjbxxIndex=xyrjbxxIndex-1:''"></div>
      <span
        style="font-size: 14px;vertical-align: top;color:#666;">共 {{ xyrjbxx.length }} 条记录，当前为第 {{ xyrjbxxIndex + 1 }} 条记录</span>
      <div title="下一页" class="next" @click="xyrjbxxIndex<xyrjbxx.length-1?xyrjbxxIndex=xyrjbxxIndex+1:''"></div>
      <div title="最后一页" class="last" @click="xyrjbxxIndex=xyrjbxx.length-1"></div>
    </div>
    <div class="item" :class="key==='SZXXMC'?'row':''" v-for="(value,key) in xyrxxData_ZH" v-if="xyrjbxx.length">
      <div class="label break">{{value}}:</div>
      <div class="value break" :title="xyrjbxx[xyrjbxxIndex][key]">
        {{xyrjbxx[xyrjbxxIndex][key]}}
      </div>
    </div>


  </div>
</template>

<script>
  import { mapState } from 'vuex'

import SQLite from '../common/SQLiteHelper'
const { util } = require('../util')
const { isNotEmpty } = util

  export default {
    name: 'CaseDetail',
    data () {
      return {
        ajjbxxData_ZH: {
          BMSAH: '部门受案号',
          TYSAH: '统一受案号',
          CBDW_MC: '承办单位',
          SLRQ: '受理日期',
          AJMC: '案件名称',
          AJLB_MC: '案件类别',
          CBBM_MC: '承办部门',
          CBR: '承办人',
          ZCJG_DWMC: '侦查机关',
          YSDW_DWMC: '移送单位',
          YSWSWH: '移送文书文号',
          YSAY_AYMC: '移送案由',
          YSQTAY_AYMCS: '移送其他案由',
          SFSWAJ: '涉外案件',
          SFDBAJ: '督办案件',
          SFGZAJ: '关注案件',
          AQZY: '案情摘要'
        },
        xyrxxData_ZH: {
          BMSAH: '部门受案号',
          TYSAH: '统一受案号',
          XYRBH: '犯罪嫌疑人编号',
          CBDW_MC: '承办单位',
          XM: '姓名',
          SFZF: '是否主犯',
          CYM: '曾用名',
          CH: '绰号',
          ZJLX_MC: '证件类型',
          ZJHM: '证件号码',
          XB_MC: '性别',
          MZ_MC: '民族',
          CSRQ: '出生日期',
          ZASNL: '作案时年龄',
          GJ_MC: '国籍',
          CSD_MC: '出生地',
          HJSZD_MC: '户籍所在地',
          ZSD_MC: '住所地',
          ZSDXXDZ: '住所地详细地址',
          GZDW: '工作单位',
          GZDWSZD_MC: '工作单位所在地',
          ZJ_MC: '职级',
          ZW: '职务',
          ZY_MC: '职业',
          SF_MC: '身份',
          SJYZK_MC: '受教育状况',
          ZZMM_MC: '政治面貌',
          RDDB_MC: '人大代表',
          ZXWY_MC: '政协委员',
          SFNCJCZZRY: '农村基层组织人员',
          WCNRJHQK_MC: '未成年人监护情况',
          FDDLR: '法定代理人',
          SZXXMC: '所在学校名称'
        },
        ajjbxx: {},
        xyrjbxx: [],
        xyrjbxxIndex: 0
      }
    },
    computed: {
      ...mapState({
        casePath: state => state.appearCourt.casePath
      })
    },
    async created () {
      // this.ajjbxx = (await UtilDLL.SqliteQuery({
      //   path: this.casePath,
      //   password: '',
      //   sql: `select * from tyyw_gg_ajjbxx`,
      // }))[0];
      this.ajjbxx = (await SQLite.ExecuteReader({
        SQL: 'select * from tyyw_gg_ajjbxx',
        Parameter: {}
      }))[0]
      // fs.writeFileSync('ajjbxx.json',JSON.stringify(this.ajjbxx,null,2))

      for (let name in this.ajjbxx) {
        if (!isNotEmpty(this.ajjbxx[name])) continue
        if (this.ajjbxx[name].toUpperCase() === 'N') {
          this.ajjbxx[name] = '否'
        } else if (this.ajjbxx[name].toUpperCase() === 'Y') {
          this.ajjbxx[name] = '是'
        }
      }

      let sqlGetXyrjbxx = `select * from tyyw_gg_xyrjbxx`
      // this.xyrjbxx = await UtilDLL.SqliteQuery({
      //   path: this.casePath,
      //   password: '',
      //   sql: `select * from tyyw_gg_xyrjbxx`,
      // });

      this.xyrjbxx = await SQLite.ExecuteReader({
        SQL: sqlGetXyrjbxx,
        Parameter: {}
      })
      // fs.writeFileSync('xyrjbxx.json',JSON.stringify(this.xyrjbxx,null,2))

      this.xyrjbxx.forEach(item => {
        for (let name in item) {
          if (!isNotEmpty(item[name])) continue
          if (item[name].toUpperCase() === 'N') {
            item[name] = '否'
          } else if (item[name].toUpperCase() === 'Y') {
            item[name] = '是'
          }
        }
      })
    }
  }
</script>
